#include "condition.h"

namespace mars {

Condition::Condition() {
    pthread_cond_init(&_cond, NULL);
}

Condition::~Condition() {
    pthread_cond_destroy(&_cond);
}

void Condition::Condition::wait(MutexLock& mutex) {
    pthread_cond_wait(&_cond, mutex.get_pthread_mutex());
}

void Condition::notify() {
    pthread_cond_signal(&_cond);
}

void Condition::notifyAll() {
    pthread_cond_broadcast(&_cond);
}

} // namespace mars
